<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class UserDeviceRepository {
    /*
     * 获取列表
     * @param $param
     * @return bool
     * @throws BasicException
     * */

    public function DeviceList($max_id) {
        $data =[];
        app('model_user_device')
            ->whereNotNull('ip')
            ->where('type',2)
            ->where('id','>',$max_id)
            ->select(DB::raw('count(*) as count_user_ip'),DB::raw('max(id) as id'),'ip')
            ->groupBy('ip')
            ->chunk(500, function ($userIps)  use (&$data){
                $newIps =  $userIps->toArray();
                $data=array_merge($data,$newIps);
        });
        return $data;
    }
}


?>